import request from '@/api/request'

// 查询所有的用户信息
export const getAllUser = async () => {
  // return request.get('/user/findAll')
  return request({
    method: 'get',
    url: '/user/findAll',
  })
}

// 登录认证
export const login = async (username: string, password: string) => {
  // return request.post('/user/authorize', { username, password })
  return request({
    method: 'post',
    url: '/user/authorize',
    data: {
      username,
      password,
    },
    //因为Java api中需要的是@requestBody，所以需要设置headers设置请求头是application/json
    headers: {
      'Content-Type': 'application/json',
    },
  })
}

//注册
export const register = async (username: string, password: string) => {
  return request({
    method: 'post',
    url: '/user/register',
    data: {
      username,
      password,
    },
  })
}
